package cn.hzu580.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {	
	
	/**
	 * 获取当前日期时间
	 * @return
	 */
	public static Date now(){
		return new Date();
	}
	
	
	/**
	 * 把日期时间转换成字符串
	 * @param currentTime
	 * @return
	 */
	public static String getString(Date currentTime) {
		   SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		   String dateString = formatter.format(currentTime);
		   return dateString;
	}
	
	
	/**
	 * 把字符串转成日期时间
	 * @param currentTime
	 * @return
	 */
	public static Date getDate(String currentTime) {
		   SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		   Date dateString;
		try {
			dateString = formatter.parse(currentTime);
			return dateString;
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;  
	}
	
}
